//***************************************************************************************

//      利用累积概率霍夫变换实现直线检测-其中canny边缘低阈值为50，高阈值为200，累积平面阈值为80

//***************************************************************************************

#include "ImageDecMat.hpp"

void ImageDecMat::on_lineDetector(cv::Mat Image1,cv::Mat& Image2)
{
    cv::Mat edgeImage;
    int lowThresh=50;
    int highThresh=200;
    int threshold=80;
    //Canny边缘检测以及灰度颜色转换
    Canny(Image1, edgeImage, lowThresh, highThresh,3);
    cv::cvtColor(edgeImage, Image2, CV_GRAY2BGR);
    
    //进行SHT
    std::vector<cv::Vec4i> lines;
    HoughLinesP(edgeImage, lines, 1, CV_PI/180, threshold,50.0,10.0);
    //循环遍历绘制每条直线
    for(size_t i;i<lines.size();++i)
    {
        cv::Vec4i l=lines[i];
        line(Image2, cv::Point(l[0],l[1]), cv::Point(l[2],l[3]), cv::Scalar(0,0,255),1,CV_AA);
    }

}
